var file_tool = ""
var clicked_window = false

function click_window(evt,prefixe)
{
	clicked_window = true
	var transfo =  svgdoc.getElementById(prefixe).getAttributeNS(null , "transform")
	transfo = transfo.substring(transfo.indexOf("(") + 1 , transfo.indexOf(")"))
	if (transfo.indexOf(",") >= 0 )
		var coeffs = transfo.split(",")
	else
		var coeffs = transfo.split(" ")
	xd1_window = parseFloat(coeffs[0]) - evt.clientX
	yd1_window = parseFloat(coeffs[1]) - evt.clientY	
}

function move_window(evt,prefixe)
{
	if (!clicked_window)
		return
	dep_x = xd1_window + evt.clientX 	
	dep_y = yd1_window + evt.clientY 	
	node = svgdoc.getElementById(prefixe)
	if (prefixe != "outil")
		node.setAttribute("transform","translate(" + dep_x + " " + dep_y + ") scale(0.8)")
	else
		node.setAttribute("transform","translate(" + dep_x + " " + dep_y + ")")
}

function add_tool(file,noeud)
{
	prefixe_tool = noeud
	file_tool = file
	getSVGObject(file_tool, tool_active)
}

function add_filesystem(file,noeud,invite,filtre,dir_default,num)
{
	prefixe_tool = noeud
	file_tool = file
	if (dir_default == "")
		 fs_path_default = default_dir
	else
		fs_path_default = dir_default
	fs_filtre = filtre
	fs_invite = invite
	fs_num = num
	getSVGObject(file_tool, tool_active)
}


function tool_active(doc_frag) 
{
	var node = svgdoc.getElementById(prefixe_tool)
	node.appendChild(doc_frag)
	if (file_tool == "svg/file_system.svg")
		fs_init()	
	if (file_tool == "svg/motif.svg")
		motif_init()	
	if (file_tool == "svg/linear.svg")
		linear_init()	
	if (file_tool == "svg/radial.svg")
		radial_init()	
	if (file_tool == "svg/texte.svg")
		texte_init() 	
	if (ASV == "6")
		svgdoc.rootElement.forceRedraw()
}

function remove_tool(prefixe)
{
	ou = svgdoc.getElementById(prefixe)
	childs = ou.childNodes
	nombre = childs.length
	for (i=nombre-1;i>=0;i--)
	{
		child=childs.item(i);
		ou.removeChild (child)
	}
}
